//
//  AddChanPinViewController.m
//  跨界收
//
//  Created by Allen on 2018/11/6.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "AddChanPinViewController.h"
#import "LYLPhotoTailoringTool.h"

@interface AddChanPinViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextFiled;

@property (weak, nonatomic) IBOutlet UIImageView *picImageview;
@property (nonatomic, strong)  NSMutableDictionary *picDic;
@end

@implementation AddChanPinViewController

- (IBAction)click:(id)sender {
    if (self.nameTextFiled.text.length == 0) {
//        [SVProgressHUD showWithStatus:@"请输入图片名称！"];
        return;
    }
    if (self.pictureBlock) {
        [self.picDic setObject:self.nameTextFiled.text forKey:@"title"];
        self.pictureBlock(self.picDic);
    }
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.picDic = [NSMutableDictionary dictionary];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPic:)];
    [self.picImageview addGestureRecognizer:tap];
    self.picImageview.userInteractionEnabled = YES;
    // Do any additional setup after loading the view from its nib.
}
- (void)tapPic:(UITapGestureRecognizer *)tap
{
    WeakSelf;
    [[LYLPhotoTailoringTool sharedTool]photoTailoring:^(UIImage *image) {
        weakSelf.picImageview.image = image;
        [weakSelf.picDic setObject:image forKey:@"image"];
    }];
}

@end
